
task PlayerDrawCount
{
loop
{
		CharaDrawCount+=1;
		if(CharaDrawCount>=DrawFrame*7)
		{
			CharaDrawCount=0;
		}

		CharaLeftMoveDrawCount+=1;

		if(CharaLeftMoveDrawCount>=DrawFrame*7)
		{
			CharaLeftMoveDrawCount=DrawFrame*4;
		}
		if(KeyStateLeft=="FREE")
		{
			CharaLeftMoveDrawCount=0;
		}

		CharaRightMoveDrawCount+=1;

		if(CharaRightMoveDrawCount>=DrawFrame*7)
		{
			CharaRightMoveDrawCount=DrawFrame*4;
		}
		if(KeyStateRight=="FREE")
		{
			CharaRightMoveDrawCount=0;
		}
	yield;
}
}

task PlayerRect
{
	loop
	{
		if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD)
		{
			PlayerRectLeft=0;
			PlayerRectUp=48;
			PlayerRectRight=48;
			PlayerRectDown=96;
		}
		else if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD)
		{
			PlayerRectLeft=0;
			PlayerRectUp=96;
			PlayerRectRight=48;
			PlayerRectDown=144;
		}
		else
		{
			PlayerRectLeft=0;
			PlayerRectUp=0;
			PlayerRectRight=48;
			PlayerRectDown=48;
		}
	yield;
	}
}

task ThPlayerRect
{
	loop
	{
			if(KeyStateLeft=="PUSH" || KeyStateLeft=="HOLD")
			{
				PlayerRectLeft=floor(CharaLeftMoveDrawCount/DrawFrame)*32;
				PlayerRectUp=49;
				PlayerRectRight=floor(CharaLeftMoveDrawCount/DrawFrame+1)*32;
				PlayerRectDown=97;
			}
			else if(KeyStateRight=="PUSH" || KeyStateRight=="HOLD")
			{
				PlayerRectLeft=floor(CharaRightMoveDrawCount/DrawFrame)*32;
				PlayerRectUp=97;
				PlayerRectRight=floor(CharaRightMoveDrawCount/DrawFrame+1)*32;
				PlayerRectDown=144;
			}
			else
			{
				PlayerRectLeft=floor(CharaDrawCount/DrawFrame)*32;
				PlayerRectUp=1;
				PlayerRectRight=floor(CharaDrawCount/DrawFrame+1)*32;
				PlayerRectDown=49;
			}
	yield;
	}
}

task Shadow(time)
{

loop(time)
{
	if(BurstMode==0){break;}
	BurstPlayerShadow;
	ascent(let i in 0..4)
	{
		BurstOptionShadow(i);
	}
	wait(2);
}

}

task BurstPlayerShadow//vC[̎cGtFNg
{
		function randrect
		{
			return(rand_int(-2,2));
		}
	let XYrect=[];
	loop(4)
	{
		XYrect=XYrect~[(PlayerRectRight-PlayerRectLeft)/2+randrect];
		XYrect=XYrect~[(PlayerRectDown-PlayerRectUp)/2+randrect];
	}
		if(GetCommonDataDefault("LightMode_PlayerBlur",0)==1){return;}

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		ObjEffect_SetTexture(obj, imgPlayer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

		ObjEffect_SetVertexXY(obj, 0, -XYrect[0], -XYrect[1]);
		ObjEffect_SetVertexXY(obj, 1, XYrect[2], -XYrect[3]);
		ObjEffect_SetVertexXY(obj, 2, XYrect[4], XYrect[5]);
		ObjEffect_SetVertexXY(obj, 3, -XYrect[6], XYrect[7]);

		ObjEffect_SetVertexUV(obj, 0,  PlayerRectLeft,  PlayerRectUp);
		ObjEffect_SetVertexUV(obj, 1,  PlayerRectRight, PlayerRectUp);
		ObjEffect_SetVertexUV(obj, 2, PlayerRectRight,  PlayerRectDown);
		ObjEffect_SetVertexUV(obj, 3, PlayerRectLeft, PlayerRectDown);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,100,127,127,255);
		}
		
		ObjEffect_SetLayer(obj, 2);
		Obj_SetAngle(obj,90);
		Obj_SetSpeed(obj,3.0);
		let Alpha=120;
		let ScaleX=0.8;
		let ScaleY=0.8;
		let DisScale=0.045;
		loop(3)
		{
		if(OnMissed){Obj_Delete(obj); break;}
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,ColorRed,ColorGreen,ColorBlue);
			}
			ObjEffect_SetScale(obj,ScaleX,ScaleY);
			ScaleX+=DisScale;
			ScaleY-=DisScale;
			Alpha-=15;
			yield;
		}
		
		Obj_Delete(obj);
}

task BurstOptionShadow(num)//IvV̎cGtFNg
{
		function randrect
		{
			return(rand_int(-1,1));
		}
	let XYrect=[];
	loop(8)
	{
	XYrect=XYrect~[14/2+randrect];
	}
		if(GetCommonDataDefault("LightMode_PlayerBlur",0)==1){return;}

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,opX[num],opY[num]);
		ObjEffect_SetTexture(obj, imgPlayer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -XYrect[0], -XYrect[1]);
	ObjEffect_SetVertexXY(obj, 1, XYrect[2], -XYrect[3]);
	ObjEffect_SetVertexXY(obj, 2, XYrect[4], XYrect[5]);
	ObjEffect_SetVertexXY(obj, 3, -XYrect[6], XYrect[7]);

		ObjEffect_SetVertexUV(obj, 0,  OptionRectLeft,  OptionRectUp);
		ObjEffect_SetVertexUV(obj, 1,  OptionRectRight, OptionRectUp);
		ObjEffect_SetVertexUV(obj, 2, OptionRectRight,  OptionRectDown);
		ObjEffect_SetVertexUV(obj, 3, OptionRectLeft, OptionRectDown);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,100,127,127,255);
		}
		
		ObjEffect_SetLayer(obj, 2);
		Obj_SetAngle(obj,90);
		Obj_SetSpeed(obj,3.0);
		let Alpha=60;
		let ScaleX=1.5;
		let ScaleY=1.5;
		let DisScale=0.045;

		loop(3)
		{
		if(OnMissed){Obj_Delete(obj); break;}
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,ColorRed,ColorGreen,ColorBlue);
			}
			ObjEffect_SetScale(obj,ScaleX,ScaleY);
			ScaleX+=0.03;
			ScaleY-=0.03;
			Alpha-=7.5;
			yield;
		}
		Obj_Delete(obj);
}

task NormalShadow
{

if(THdot)
{
	alternative(PlayerType)
	case("A")
	{
		OptionRectLeft=80;
		OptionRectUp=160;
		OptionRectRight=96;
		OptionRectDown=176;
	}
	case("B")
	{
		OptionRectLeft=64;
		OptionRectUp=160;
		OptionRectRight=80;
		OptionRectDown=176;
	}
	case("C")
	{
		OptionRectLeft=176;
		OptionRectUp=144;
		OptionRectRight=192;
		OptionRectDown=160;
	}
	case("D")
	{
		OptionRectLeft=96;
		OptionRectUp=160;
		OptionRectRight=112;
		OptionRectDown=176;
	}
}
else
{
	OptionRectLeft=3;
	OptionRectUp=162;
	OptionRectRight=17;
	OptionRectDown=176;
}

loop
{
	if(BurstMode==0 && MissTime==0)
	{
		NormalPlayerShadow;
		ascent(let i in 0..4)
		{
			NormalOptionShadow(i);
		}
		count=0;
	}
	wait(2);
}
}


task NormalPlayerShadow//vC[̎cGtFNg
{
		function randrect
		{
			return(rand_int(-2,2));
		}
	let XYrect=[];
	loop(4)
	{
		XYrect=XYrect~[(PlayerRectRight-PlayerRectLeft)/2+randrect];
		XYrect=XYrect~[(PlayerRectDown-PlayerRectUp)/2+randrect];
	}
		if(GetCommonDataDefault("LightMode_PlayerBlur",0)==1){return;}

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		ObjEffect_SetTexture(obj, imgPlayer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -XYrect[0], -XYrect[1]);
	ObjEffect_SetVertexXY(obj, 1, XYrect[2], -XYrect[3]);
	ObjEffect_SetVertexXY(obj, 2, XYrect[4], XYrect[5]);
	ObjEffect_SetVertexXY(obj, 3, -XYrect[6], XYrect[7]);

		ObjEffect_SetVertexUV(obj, 0,  PlayerRectLeft,  PlayerRectUp);
		ObjEffect_SetVertexUV(obj, 1,  PlayerRectRight, PlayerRectUp);
		ObjEffect_SetVertexUV(obj, 2, PlayerRectRight,  PlayerRectDown);
		ObjEffect_SetVertexUV(obj, 3, PlayerRectLeft, PlayerRectDown);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,100,127,127,255);
		}
		
		ObjEffect_SetLayer(obj, 2);
		Obj_SetAngle(obj,90);
		Obj_SetSpeed(obj,1.5);
		let Alpha=120;
		let ScaleX=1.0;
		let ScaleY=1.0;
		let DisScale=0.000;
		let ady=0;

		let R;
		let G;
		let B;
		if(PlayerType=="A"){R=0;G=0;B=150;}
		if(PlayerType=="B"){R=150;G=0;B=0;}
		if(PlayerType=="C"){R=150;G=0;B=150;}
		if(PlayerType=="D"){R=50;G=205;B=50;}

		loop(3)
		{
		if(OnMissed){Obj_Delete(obj); break;}
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}
			ObjEffect_SetScale(obj,ScaleX,ScaleY);
			ScaleX+=DisScale;
			ScaleY-=DisScale;
			Alpha-=7.5*2*5/3;
			yield;
		}
		
		Obj_Delete(obj);
}

task NormalOptionShadow(num)//IvV̎cGtFNg
{
		function randrect
		{
			return(rand_int(-1,1));
		}
	let XYrect=[];
	loop(8)
	{
	XYrect=XYrect~[14/2+randrect];
	}
		if(GetCommonDataDefault("LightMode_PlayerBlur",0)==1){return;}

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,opX[num],opY[num]);
		ObjEffect_SetTexture(obj, imgPlayer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -XYrect[0], -XYrect[1]);
	ObjEffect_SetVertexXY(obj, 1, XYrect[2], -XYrect[3]);
	ObjEffect_SetVertexXY(obj, 2, XYrect[4], XYrect[5]);
	ObjEffect_SetVertexXY(obj, 3, -XYrect[6], XYrect[7]);

		ObjEffect_SetVertexUV(obj, 0,  OptionRectLeft,  OptionRectUp);
		ObjEffect_SetVertexUV(obj, 1,  OptionRectRight, OptionRectUp);
		ObjEffect_SetVertexUV(obj, 2, OptionRectRight,  OptionRectDown);
		ObjEffect_SetVertexUV(obj, 3, OptionRectLeft, OptionRectDown);

		ObjEffect_SetLayer(obj, 2);
		Obj_SetAngle(obj,90);
		Obj_SetSpeed(obj,1.5);
		let Alpha=60;
		let ScaleX=1.2;
		let ScaleY=1.2;
		let DisScale=0.05;

		let R;
		let G;
		let B;
		if(PlayerType=="A"){R=0;G=0;B=150;}
		if(PlayerType=="B"){R=150;G=0;B=0;}
		if(PlayerType=="C"){R=150;G=0;B=150;}
		if(PlayerType=="D"){R=50;G=205;B=50;}

		loop(3)
		{
		if(PlayerType=="C" && GetKeyState(VK_SLOWMOVE)==KEY_HOLD){break;}
		if(OnMissed){Obj_Delete(obj); break;}
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,R,G,B);
			}
			ObjEffect_SetScale(obj,ScaleX,ScaleY);
			ScaleX+=DisScale;
			ScaleY-=DisScale;
			Alpha-=7.5*5/3;
			yield;
		}
		Obj_Delete(obj);
}

task ObjPlayerDraw//GtFNgIuWFNgɂvC[\
{
	let XYrect=[];
	loop(4)
	{
		XYrect=XYrect~[(PlayerRectRight-PlayerRectLeft)/2];
		XYrect=XYrect~[(PlayerRectDown-PlayerRectUp)/2];
	}

  		let obj = Obj_Create(OBJ_EFFECT);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		ObjEffect_SetTexture(obj, imgPlayer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD);
		ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -XYrect[0], -XYrect[1]);
	ObjEffect_SetVertexXY(obj, 1, XYrect[2], -XYrect[3]);
	ObjEffect_SetVertexXY(obj, 2, XYrect[4], XYrect[5]);
	ObjEffect_SetVertexXY(obj, 3, -XYrect[6], XYrect[7]);

		ObjEffect_SetVertexUV(obj, 0,  PlayerRectLeft,  PlayerRectUp);
		ObjEffect_SetVertexUV(obj, 1,  PlayerRectRight, PlayerRectUp);
		ObjEffect_SetVertexUV(obj, 2, PlayerRectRight,  PlayerRectDown);
		ObjEffect_SetVertexUV(obj, 3, PlayerRectLeft, PlayerRectDown);

		ascent(let i in 0..4)
		{
		ObjEffect_SetVertexColor(obj,i,255,255,127,127);
		}
		
		ObjEffect_SetLayer(obj, 3);

		loop(3)
		{
			yield;
		}
		
		Obj_Delete(obj);
}

task ShotHit(let x, let y, let angle, let vang, let speed,R,G,B)
{
	let obj = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj, imgShot3);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetLayer(obj,2);
	
	ObjEffect_SetVertexXY(obj, 0, -8, -32);
	ObjEffect_SetVertexXY(obj, 1, 8, -32);
	ObjEffect_SetVertexXY(obj, 2, 8, 32);
	ObjEffect_SetVertexXY(obj, 3, -8, 32);

	ObjEffect_SetVertexUV(obj, 0, 0, 0);
	ObjEffect_SetVertexUV(obj, 1, 16, 0);
	ObjEffect_SetVertexUV(obj, 2, 16, 64);
	ObjEffect_SetVertexUV(obj, 3, 0, 64);

	ObjEffect_SetAngle(obj,0,0,angle+90);
	Obj_SetPosition(obj, x, y);
	Obj_SetSpeed(obj,speed);
	Obj_SetAngle(obj,angle);

	let Alpha = 200;
	while(Alpha > 0)
	{
		Alpha-=20;
		yield;
		ascent(i in 0..4){ObjEffect_SetVertexColor(obj, i, Alpha,R,G,B);}
	}
	Obj_Delete(obj);
}
